<!--
 * @description  : 案件-询问通知书
 * @descriptionDetail: 案件-询问通知书
 * @copyright    : 浙江烟草
 * @author       : dw
 * @create       : 2022-10-09 22:21:21
-->
<template>
  <view class="page">
    <!-- #ifdef H5-ONLY -->
    <theme-navbar :is-white="false" :title="navTitle" :custom-back="goBack" style="z-index: 99999">
      <view class="nav-right-icon" @click="printOrDown(state.canEdit)">
        {{ state.canEdit?'预览':'打印' }}
      </view>
    </theme-navbar>
    <!-- #endif -->
		<!-- #ifdef H5-WECHAT || H5-EMP -->
		<fab-button :content="state.canEdit?fContent:fContents" @fabtrigger="fabtrigger" />
		<!-- #endif -->
    <!-- 表单开始 -->
    <view class="main-content">
      <view style="width: calc(100% + 30px);">
        <form-section title="询问通知书"></form-section>
      </view>

      <u-form :label-position="labelPosition" :model="queryRecordForm" :error-type="errorType" :rules="rules" class="form-content" ref="uForm">
        <u-form-item
            label="文书编号"
            prop="fullDocNo"
            :required="isRequired"
            :label-position="labelPosition"
            :label-width="labelWidth"
        >
          <u-input
              :disabled="!state.canEdit"
              placeholder="请输入送达地点"
              v-model="queryRecordForm.fullDocNo"
          />
        </u-form-item>

        <u-form-item
            label="当事人"
            :label-width="labelWidth"
            :required="true"
            prop="party"
            right-icon="arrow-right"
        >
          <u-input placeholder="请输入" input-align="right" :disabled="!state.canEdit" v-model="queryRecordForm.party" @click="()=>{if(state.canEdit) partySelectShow = true}" />
        </u-form-item>

        <!-- 案由   -->
        <u-form-item
            label="案由"
            :label-position="labelPosition"
            right-icon="arrow-right"
            :required="true"
            prop="causeOfAction" ref="caseChangeRef">
          <u-input
              type="textarea"
              height="35"
              :auto-height="true"
              :disabled="!state.canEdit"
              placeholder="请选择"
              v-model="queryRecordForm.causeOfAction"
              @click="choiceCaseOfAction(state.canEdit)"
          ></u-input>
        </u-form-item>

        <u-form-item
            label="询问时间"
            :required="isRequired"
            prop="arriveEndTime"
            :label-position="labelPosition"
            right-icon="arrow-right"
            ref="arriveEndTime"
        >
          <u-input
              placeholder="请输入询问时间"
              :disabled="!state.canEdit"
              :custom-style="pointerStyle"
              :clearable="false"
              v-model="queryRecordForm.arriveEndTime"
              @click="()=>{if(state.canEdit) clickDateBtn('arriveEndTime')}"
          />
        </u-form-item>

        <u-form-item  label="询问地点"
                      :required="isRequired"
                      prop="handlingAddr"
                      :label-position="labelPosition"
                      ref="handlingAddr">
          <u-input type="textarea" height="35" :auto-height="true" placeholder="询问地点" :disabled="!state.canEdit" v-model="queryRecordForm.handlingAddr" />
        </u-form-item>

        <u-form-item
            label="依据"
            prop="queryDes"
            :bordebottom="false"
            label-width="auto"
            label-position="top"
        >
          <u-input type="textarea" height="35" :auto-height="true" placeholder="依据" :disabled="true" v-model="queryRecordForm.queryDes" />
        </u-form-item>

        <u-form-item
            label="请携带以下材料"
            :required="isRequired"
            :label-position="labelPosition"
            prop="materials"
            ref="handleDescRef"
        >
          <u-checkbox-group
              :wrap="true"
              :disabled="!state.canEdit"
              :label-disabled="true"
              @change="checkboxChange"
          >
            <u-checkbox
                :name="item.value"
                v-for="(item, index) in handleList"
                :key="index"
                v-model="item.checked"
            >
              <view>
                {{ item.name }}
              </view>
            </u-checkbox>
          </u-checkbox-group>
        </u-form-item>
        <u-form-item
            v-if="isReadBoolean && isReadBoolean.includes('isRests')"
            label=""
            prop="materialOne"
            :bordebottom="false"
            label-width="auto"
            label-position="left"
        >
          <u-input type="textarea" height="35" :auto-height="true" placeholder="请输入其他" :disabled="!state.canEdit" v-model="queryRecordForm.materialOne" />
        </u-form-item>

        <u-form-item
            label=""
            prop="alkItem"
            :bordebottom="false"
            label-width="auto"
            label-position="left"
        >
          <u-input type="textarea" height="35" :auto-height="true" placeholder="请选择" :disabled="true" v-model="queryRecordForm.chargeDes" />
        </u-form-item>


        <u-form-item prop="handlingPerson" ref="handlingPerson">
          <view class="person-info">
            <view class="p-title">
              <view class="doc-sub-required">
                *
              </view>
              <view class="doc-sub-title">
                联系人
              </view>
              <view class="uicon-sty" @click="docSub(state.canEdit, '01')">
                <u-icon name="plus-circle" :color="$theme.u_type_primary" size="40"></u-icon>
              </view>
            </view>
            <u-input placeholder="请输入" type="textarea" height="100" :auto-height="true" :disabled="!state.canEdit" v-model="queryRecordForm.handlingPerson" />
          </view>
        </u-form-item>

        <u-form-item prop="connectPhone" :required="isRequired" label="联系电话">
          <u-input placeholder="请输入联系电话" :disabled="!state.canEdit" type="number" v-model="queryRecordForm.connectPhone" />
        </u-form-item>

        <u-form-item prop="undertaker" ref="personChangeRef">
          <view class="person-info">
            <view class="p-title">
              <view class="doc-sub-required">
                *
              </view>
              <view class="doc-sub-title">
                承办人（签名）
              </view>
              <view class="uicon-sty" @click="docSub(state.canEdit, '02')">
                <u-icon name="plus-circle" :color="$theme.u_type_primary" size="40"></u-icon>
              </view>
            </view>
            <u-input placeholder="请输入" type="textarea" height="100" :auto-height="true" :disabled="!state.canEdit" v-model="queryRecordForm.undertaker" />
          </view>
        </u-form-item>

        <u-form-item
            label="文书日期"
            :required="isRequired"
            prop="docDate"
            :label-position="labelPosition"
            right-icon="arrow-right"
            ref="docDate"
        >
          <u-input
              placeholder="请输入文书日期"
              :disabled="!state.canEdit"
              :custom-style="pointerStyle"
              :clearable="false"
              v-model="queryRecordForm.docDate"
              @click="()=>{if(state.canEdit) clickDateBtn('docDate')}"
          />
        </u-form-item>

        <u-form-item
            label="送达方式"
            :required="isRequired"
            :label-position="labelPosition"
            prop="serviceStyle"
        >
          <dic-input
              :keyWord="$u.dic.DIC_KEYS.BSC_SERVICE_TYPE"
              :dicCode="queryRecordForm.serviceStyle"
              inputAlign="left"
              type="select"
              :select-open="
              dicSelectOpen('serviceStyle', $u.dic.DIC_KEYS.BSC_SERVICE_TYPE)
            "
              placeholder="请选择"
              v-model="queryRecordForm.serviceStyleName"
              @changeInputModelData="
              (name) => {
                $set(queryRecordForm, 'serviceStyleName', name);
              }
            "
              @click="
              showDic(
                $u.dic.DIC_KEYS.BSC_SERVICE_TYPE,
                queryRecordForm.serviceStyle,
                'serviceStyle'
              )
            "
          />
        </u-form-item>


        <u-form-item
            label="送达地点"
            label-width="200"
            :required="true"
            prop="serviceAddr"
        >
          <u-input
              :disabled="!state.canEdit"
              type='textarea'
              placeholder="请输入送达地点"
              v-model="queryRecordForm.serviceAddr"
          />
        </u-form-item>
      </u-form>
    </view>
    <!-- 底部按钮开始 -->
    <view class="submit-btns btn-other-cls" v-if="state.canEdit">
      <u-button plain class="u-btn" type="primary" @click="submitBtn('save')">
        保存
      </u-button>
      <u-button class="u-btn" type="primary" @click="submitBtn('submit')">
        提交
      </u-button>
    </view>

    <!-- 底部按钮结束 -->
    <!-- 人员选择 -->
    <u-popup mode="bottom" height="80%" v-model="personSelectShow">
      <person-selection :params="psParam" @choose="handlerChoosePerson"></person-selection>
    </u-popup>

    <u-picker mode="time" :params="paramsDate" v-model="arriveEndTime" @confirm="changeDate('arriveEndTime',$event)">
    </u-picker>

    <u-picker mode="time" :params="paramsDate1" v-model="docDate" @confirm="changeDate('docDate',$event)">
    </u-picker>

    <!-- 当事人   -->
    <u-popup mode="bottom" height="80%" v-model="partySelectShow">
      <select-party-component :params="partyParams" :isCheckBox="false" @choose="handlerChooseParty"></select-party-component>
    </u-popup>


    <u-popup mode="bottom" height="80%" v-model="showFieldTpl">
      <doc-form-content-tep
        :params="fieldParam"
        formName="queryRecordForm"
        :fieldkey="fieldKey"
        @choice="choiceFieldTpl"
      ></doc-form-content-tep>
    </u-popup>
    <!-- 下拉选择用 -->
    <dic-choice
      :keyWord="dicKeyWords"
      :currentSelect="dicCurrentSelect"
      v-model="dicShow"
      @confirm="selectDicConfirm"
    ></dic-choice>


  </view>
</template>

<script>
	import caseCommon from '../caseCommonMixin.js';
	import officeService from '@/service/case/office.service.js';
	import PersonSelection from '@/pages/case/components/personSelection.vue';
	import {
		IDENTITY_TYPE
	} from '@/common/common_enum.js';
	import DicChoice from '@/components/dic_choice.vue';
	import DicInput from '@/components/dic_input.vue';
	import moment from 'moment';
	import GoodsListCom from '../components/goodsListComponent.vue';
	import caseService from '@/service/case/case.service.js';
	import zjCommonService from '@/service/common/common.service';
	import SelectPartyComponent from '../components/selectPartyComponent.vue';
	import DocFormContentTep from '../components/docFormContentTemplate.vue';
	import FormSection from '@/components/form-section.vue';
	import {
		CASE_DOC_NAME_PATH
	} from '@/service/case/mapping/index.js';
	import {
		L_BSC_IDCARD_TYPE
	} from '@/service/intelligence/mapping/enum.js';
	import fabButton from '@/components/uni-fab.vue';
  import commonService from "@/service/common/common.service";

	export default {
		components: {
			PersonSelection,
			GoodsListCom,
			SelectPartyComponent,
			FormSection,
			DocFormContentTep,
			DicInput,
			DicChoice,
			fabButton
		},
		mixins: [caseCommon],
		data() {
			return {
				moment,
				IDENTITY_TYPE,
        paramsDate1: {
          year: true,
          month: true,
          day: true,
          hour: false,
          minute: false,
          second: false,
          timestamp: false,
        },
				paramsDate: {
					year: true,
					month: true,
					day: true,
					hour: true,
					minute: true,
					second: true,
					timestamp: true,
				},
				border: false,
				errorType: ['border-bottom', 'message'],
				isRequired: true,
				labelWidth: '220',
				labelPosition: 'top',
				maxLength: 9999,
				isShowAskS: false,
				isShowAskE: false,
				isCanClick: false, // 是否可点击承办人按钮
				employeeLst: [], // 选择人员数据
				perFlag: '', // 选择人员类型 询问人or记录人
				caseParam: {}, // 上个页面传过来的参数
				queryRecordForm: {},
				doc: {},
				personSelectShow: false,
				psParam: {},
				goodsData: {}, // 物品数据
				baseInfo: {},
				params: {},
				orginalCaseClueList: [],
				// dic_select 是否显示
				dicShow: false,
				// dic 关键字
				dicKeyWords: '',
				// dic 当前选择项
				dicCurrentSelect: '',
				dicType: '',
				rules: {
          fullDocNo: [{
            required: true,
            message: '请输入文书编号',
            trigger: ['change', 'blur'],
          }, ],
          party: [{
            required: true,
            message: '当事人不能为空',
            trigger: ['change', 'blur'],
          }, ],
          causeOfAction: [{
            required: true,
            message: '案由不能为空',
            trigger: ['change', 'blur'],
          }, ],
          arriveEndTime: [{
            required: true,
            message: '询问时间不能为空',
            trigger: ['change', 'blur'],
          }, ],
          handlingAddr: [{
            required: true,
            message: '询问地点不能为空',
            trigger: ['change', 'blur'],
          }, ],
          handlingPerson: [{
            required: true,
            message: '联系人不能为空',
            trigger: ['change', 'blur'],
          }, ],
          connectPhone: [{
            required: true,
            message: '联系电话不能为空',
            trigger: ['change', 'blur'],
          }, ],
          undertaker: [{
            required: true,
            message: '承办人（签名）不能为空',
            trigger: ['change', 'blur'],
          }, ],
          docDate: [{
            required: true,
            message: '文书日期不能为空',
            trigger: ['change', 'blur'],
          }, ],
          serviceStyle: [{
            required: true,
            message: '送达方式不能为空',
            trigger: ['change', 'blur'],
          }, ],
          serviceAddr: [{
            required: true,
            message: '送达地点不能为空',
            trigger: ['change', 'blur'],
          }, ]
				},
				btnType: '',
				isReadBoolean: [],
				partySelectShow: false,
				partyNames: '', // 当事人名称
				partyList: [], // 当事人列表
				partyParams: {}, // 传给当事人选择页面的参数
				ifborder: false,
				fContent: [{
					iconPath: require('@/static/oview.png'),
					selectedIconPath: require('@/static/oview.png'),
					text: '预览',
					active: false,
				}],
				fContents: [{
					iconPath: require('@/static/dy.png'),
					selectedIconPath: require('@/static/dy.png'),
					text: '打印',
					active: false,
				}],
				// h5端部分浏览器input设置disabled后点击事件失效 2023-10-27 fsx start
				pointerStyle: {
					marginRight: "5px",
					pointerEvents: "none !important"
				},
				// h5端部分浏览器input设置disabled后点击事件失效 2023-10-27 fsx end
        handleList: [
          {
            name: "1.身份证明",
            value: "isIdentity",
            checked: false,
            disabled: false,
            field: "handleDesc01",
          },
          {
            name: "2.营业执照",
            value: "isLicense",
            checked: false,
            disabled: false,
            field: "handleDesc02",
          },
          {
            name: "3.烟草专卖零售许可证",
            value: "isTobacco",
            checked: false,
            disabled: false,
            field: "handleDesc03",
          },
          {
            name: "4.其他:",
            value: "isRests",
            checked: false,
            disabled: false,
            field: "handleDesc04",
          },
        ],
        queryDes: '依据《烟草专卖行政处罚程序规定》第三十八条第二款的规定，你（单位）有如实回答询问、协助调查的义务。',
        chargeDes: '如你（单位）委托其他人员接受询问调查的，委托代理人应当同时提供授权委托书及委托代理人身份证明。',
        isTransCase: false,
        userType: '',
        arriveEndTime: false,
        docDate: false,
        inquiryNoticeUuid: ""
			};
		},
		watch: {
		},
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		},
		onLoad(preParams) {
			this.caseParam = this.getRouteParam();
			this.psParam.caseUuid = this.caseParam.caseUuid;
			caseService
				.getCaseInfoById({
					caseUuid: this.psParam.caseUuid,
				})
				.then((res) => {
					this.$modal.hideLoading();
					this.baseInfo = res.bean || {};
					this.getDefaultCaseClue();
				})
				.catch((res) => {
					this.$modal.hideLoading();
					this.$u.toast(res.msg);
				});
		},
		mounted() {
			this.docStep((docInfo) => {
				this.doc = docInfo;
				this.setRightBtns();
			});
			this.initDocData();
      this.getDoodsRegs();
		},
		methods: {
			getDefaultCaseClue() {
				caseService
					.casePropertyList()
					.then((res) => {
						if (!res.success) {
							return;
						}
						if (res.data && res.data.length > 0) {
							if (this.baseInfo.casePropertyRelList && this.baseInfo.casePropertyRelList.length > 0) {
								this.orginalCaseClueList = [];
								for (let i = 0; i < this.baseInfo.casePropertyRelList.length; i++) {
									let op = this.baseInfo.casePropertyRelList[i];
									for (let j = 0; j < res.data.length; j++) {
										if (res.data[j].casepropUuid == op.casepropUuid) {
											let opx = res.data[j];
											this.objMerge(opx, op);
											this.orginalCaseClueList.push(opx);
											this.params.orginalCaseClueList = this.orginalCaseClueList;
											break;
										}
									}
								}
							}
						}
					})
					.catch((err) => {
						console.log('查询失败:' + err);
					});
			},
      docSub(flag, userType) {
        if (flag) {
          this.userType = userType;
          this.personSelectShow = true;
          this.psParam = {
            min: 2,
            caseUuid: this.psParam.caseUuid,
          };
        }
      },
			dicSelectOpen(type, keyWords) {
				if (type == this.dicType) {
					if (this.dicKeyWords == keyWords && this.dicShow) {
						return true;
					}
					return false;
				}
			},
			showDic(key, cur, type) {
				if (!this.state.canEdit) return;
				if (this.dicShow) return;
				this.dicKeyWords = key;
				this.dicCurrentSelect = cur;
				this.dicShow = true;
				this.dicType = type;
			},
			addAskPsn() {
				if (this.state.canEdit) {
					this.partySelectShow = true;
				}
			},
			selectDicConfirm(e) {
        if (this.dicKeyWords == this.$u.dic.DIC_KEYS.BSC_SERVICE_TYPE) {
          this.queryRecordForm.serviceStyleName = e[0].label;
          this.queryRecordForm.serviceStyle = e[0].extra.bcbCode;
        }
			},
			initDocData() {
				this.$u.loading('加载中...');
				officeService
					.docFields(this.caseParam.docUuid, true)
					.then((docConfigs) => {
						if (docConfigs.success) {
							this.docFields = [...docConfigs.data];
							let parms = {
								id: this.caseParam.id,
								docUuid: this.caseParam.docUuid,
								bizUuid: this.caseParam.bizUuid,
							};
							// 获取询问笔录数据
							officeService
								.getDocInquiryNotice(parms)
								.then((res) => {
									this.$u.hideLoading();
									let [tiInfo, rs] = [{}, {}];
									if (res.success && res.data.length === 2) {
										tiInfo = res.data[0];
										rs = res.data[1];
										Object.keys(tiInfo).forEach((key) => {
											rs[key] = tiInfo[key];
										});
									} else {
										rs = res.data[0];
									}

                  let handleList = this.handleList;
                  for(let item in rs) {
                    handleList.forEach((ele) => {
                      if (ele.value === item) {
                        ele.checked = rs[item];
                        this.isReadBoolean.push(ele.value)
                      }
                    })
                  }
									this.queryRecordForm = rs;
                  this.inquiryNoticeUuid = rs.inquiryNoticeUuid;
                  this.queryRecordForm.queryDes = this.queryDes
                  this.queryRecordForm.chargeDes = this.chargeDes

									this.getPartyInfoList();
								})
								.catch((er) => {
									console.log(er);
									this.$u.hideLoading();
									this.$u.toast(er);
								});
						} else {
							this.$u.toast(docConfigs.msg);
						}
					})
					.catch((er) => {
						console.log(er);
						this.$u.hideLoading();
						this.$u.toast(er);
					});
			},
      // 获取审批通过的先保书
      getDoodsRegs() {
        officeService.getDoodsRegs({
          caseUuid: this.queryRecordForm.bizUuid,
        }).then((res) => {
          if (res.success) {
            this.handleGoodsSelect(res.data);
          }
        }).catch((err) => {
          this.$u.toast(err);
        });
      },
			checkboxChange(e) {
				this.isReadBoolean = e;
				if (this.isReadBoolean) {
					this.queryRecordForm.isRead = 1;
				}
			},
			// 获取当事人list（单选）
			getPartyInfoList() {
				caseService
					.getPartyInfoList(this.caseParam.bizUuid)
					.then((res) => {
						if (!res.success) return;
						let names = [];
						let uuids = [];
						this.partyList = res.data.length > 0 ? res.data : [];
						this.partyList.forEach((itm) => {
							names.push(itm.partyName);
							uuids.push(itm.partyUuid);
							if (this.queryRecordForm.partyUuids === itm.partyUuid) {
								itm.check = true;
							}
						});
						this.partyParams = {
							list: this.partyList,
							selUsersStr: this.queryRecordForm.partyUuids,
						};
					})
					.catch((err) => {
						this.partyList = [];
						console.log(err);
					});
			},
			// 选择当事人回调事件
			handlerChooseParty(e) {
				this.partySelectShow = false;
				this.queryRecordForm.byAskPsn = e.partyNames;
				this.partyParams.selUsersStr = e.partyUuids;
				this.queryRecordForm.partyUuids = e.partyUuids;
				this.queryRecordForm.byAskNation = e.list[0].nation; // 民族
				this.queryRecordForm.byAskSex = e.list[0].partyType; // 性别
				this.queryRecordForm.byAskPhone = e.list[0].phone; // 联系电话
				this.queryRecordForm.byAskIdType = e.list[0].idCardType; // 证件类型
				this.queryRecordForm.byAskIdNo = e.list[0].idCard; // 证件号码
      				this.queryRecordForm.byAskAddr = e.list[0].busiAddr; // 经营地址
				this.queryRecordForm.byAskHomeAddr = e.list[0].idCardAddr; // 证件地址
      				this.queryRecordForm.byAskAge = e.list[0].age; // 年龄
				this.$forceUpdate();
			},
			// 查询案件物品信息表
      getGoodsList() {
        officeService.caseGoodsPunishList(this.caseParam.caseUuid).then(res => {
          if (res.success) {
            let num = 0;
            let amt = 0.00;
            let sellNum = 0;
            let sellAmt = 0.00;
            res.data && res.data.forEach(g => {
              num += g.qty;
              amt += g.amt;
              sellNum += (g.illegalQty || 0);
              sellAmt += (g.illegalAmt || 0);
            });
            this.goodsData = {
              list: res.data,
              goodsUnitNum: parseFloat(num.toFixed(2)),
              goodsAmt: parseFloat(amt.toFixed(2)),
              sellNum: parseFloat(sellNum.toFixed(2)),
              sellAmt: parseFloat(sellAmt.toFixed(2)),
            }
          }
        });

      },
			// 设置右侧标题
			setRightBtns() {
				// #ifdef H5-DINGDING
				this.$deviceApi.setRight(this.state.canEdit ? '预览' : '打印', () => {
					this.printOrDown(this.state.canEdit);
					this.setRightBtns();
				}, true, true);
				// #endif
			},
			fabtrigger(btn) {
				if (btn.index == 0) {
					this.printOrDown(this.state.canEdit);
				}
			},
			// 打印/预览
			printOrDown(flag) {
				if (flag) {
					// 调接口预览
					this.submitDocInfo('preview');
				} else {
					this.downloadFile(this.doc.pdfFileId);
				}
			},
			downloadFile(fileId, titleName, isDownload) {
				let pdfIds = fileId;
				if (!pdfIds) {
					this.$u.toast('没有文书');
					return;
				}
				this.setRouteParam({
					fileId: pdfIds,
					fileName: titleName,
					isDownload: isDownload,
					isSign: CASE_DOC_NAME_PATH[this.doc?.configIns?.docCode]?.isSign,
				});
				this.$u.route('pages/commonPage/printerComponent');
			},
			clickDateBtn(type) {
				this[type] = true;
			},
			// 表单验证
			validForm(type) {
				let basicValid = false;
				this.btnType = type;
				this.$refs.uForm.validate((valid) => {
					if (valid) {
						if (!this.queryRecordForm.partyUuids) {
							this.$u.toast('请选择当事人!');
							return;
						}
						basicValid = true;
						console.log('表单验证通过');
					} else {
						basicValid = false;
						console.log('表单验证失败');
					}
				});
				return basicValid;
			},
			submitBtn(type) {
				// 点击提交、保存按钮
				let flag = this.validForm(type);
				if (flag) {
					if (type == 'submit') {
						this.$modal.confirm('完成后不可修改，请确认是否填写完整准确无误？', () => {
							this.submitDocInfo(type);
						});
					} else {
						this.submitDocInfo(type);
					}
				}
			},
			submitDocInfo(type) {
				// 保存/提交
				let {
					id,
					docUuid,
					titemUuid
				} = this.caseParam;
				this.queryRecordForm.caseUuid = this.psParam.caseUuid;
				this.$u.loading('数据保存中...');

        let filterList = this.handleList.filter((item) => item.checked);
        if (filterList.length == 0) {
          this.$u.toast("请至少选择一个携带材料!");
          return;
        }

        let handleList = this.handleList;
        handleList.forEach((ele) => {
          this.queryRecordForm[ele.value] = ele.checked;
          if (ele.value === 'isRests' && ele.checked) {
            this.queryRecordForm['materials'] = 'isRests'
          }
          if (ele.value === 'isRests' && !ele.checked) {
            this.queryRecordForm['materialOne'] = ''
          }
        })
        let queryRecordForm = this.$u.deepClone(this.queryRecordForm);
        let delArr = [
            'serviceStyleName', 'modifyTime', "remark", "isActive",
          'creator', 'modifier', 'ownDeptUuid', 'ownOrgUuid', 'queryDes', 'chargeDes'
        ]
        if (queryRecordForm) {
          delArr.forEach(ele => {
            delete queryRecordForm[ele]
          })
        }

				officeService.saveDocInquiryNotice(queryRecordForm, docUuid, titemUuid, id, this.caseParam.type).then((res) => {
					this.$u.hideLoading();
					if (res.success) {
						this.queryRecordForm = {
							...this.queryRecordForm,
							...res.bean,
						};
						try {
							if (!this.doc) this.doc = res.data[0];
						} catch (e) {
							console.log(e);
						}
						if (type == 'submit') {
							this.$u.loading('数据提交中...');
              let submitQueryRecordForm = this.$u.deepClone(this.queryRecordForm);
              if (submitQueryRecordForm) {
                delArr.forEach(ele => {
                  delete submitQueryRecordForm[ele]
                })
              }
							officeService.submitDocInquiryNotice(submitQueryRecordForm, docUuid, titemUuid, id, this.caseParam.type).then((res) => {
								this.$u.hideLoading();
								this.$u.toast(res.msg);
								this.saveBehaviorLog(1, this.caseParam, this.doc);
								if (res.success) {
									this.backPrev({
										paramKey: 'offiList',
										param: {
											caseUuid: this.caseParam.bizUuid,
											caseCode: this.caseParam.caseCode,
											caseType: this.caseParam.caseType,
										},
									});
								}
							});
						} else if (type == 'preview') {
							this.$u.loading('生成PDF中...');
							officeService.buildLocalPunish('/survey/doc-inquiry-notice', this.doc.docInsUuid).then((pdfId) => {
								this.$u.hideLoading();
								if (pdfId.success) {
									this.downloadFile(pdfId.bean, '预览', false);
								} else {
									this.$u.toast(pdfId.msg);
								}
							});
						} else {
							this.saveBehaviorLog(0, this.caseParam, this.doc);
							this.$u.toast(res.msg);
						}
					} else {
						this.$u.hideLoading();
						this.$u.toast(res.msg);
					}
				});
			},
			// 添加询问人和记录人
			addUndertaker(flag) {
				if (flag == 'aPer') {
					this.psParam.min = 2;
					delete this.psParam.max;
				} else {
					this.psParam.max = 1;
					delete this.psParam.min;
				}
				this.perFlag = flag;
				this.personSelectShow = true;
			},
			// 选择执行人（询问人、记录人）
			handlerChoosePerson(e) {
				this.personSelectShow = false;
				this.employeeLst = [...e];
				let tIds = [];
				let tNames = [];
				this.employeeLst.forEach((el) => {
					tIds.push(el.personUuid);
					tNames.push(`${el.personName}(${el.inspectionCertNo})`);
				});
        if (this.userType === '01') {
          this.queryRecordForm['handlingPerson'] = tNames.join(',');
        } else if (this.userType === '02') {
          this.queryRecordForm['undertakerUuids'] = tIds.join(',');
          this.queryRecordForm['undertaker'] = tNames.join(',');
        }
			},
			changeDate(type, e) {
        if (type === 'docDate') {
          this.queryRecordForm[type] = this.$u.date(e.timestamp, 'yyyy年mm月dd日');
        } else {
          this.queryRecordForm[type] = this.$u.date(e.timestamp, 'yyyy年mm月dd日 hh时MM分');
        }
			},
			getWidth() {
				let w = this.$u.sys().windowWidth - 32 + 'px';
				return w;
			},
      updateBackState(param) {
        if (param.caseSelectionData) {
          // 案由选择回调
          let arr = [];
          let arrIds = [];
          param.caseSelectionData.map((itm) => {
            itm.caseUuid = this.queryRecordForm.caseUuid;
            arr.push(itm.caseProperty);
            arrIds.push(itm.casepropUuid);
          });
          this.isTransCase =
              arrIds.includes("1") ||
              arrIds.includes("2") ||
              arrIds.includes("3") ||
              arrIds.includes("27");
          this.queryRecordForm.casePropertyRelList = param.caseSelectionData;
          this.$set(this.queryRecordForm, 'causeOfAction', arr.join("、"));
          this.getLegalPunishData(param.caseSelectionData);
        }
      },
      getLegalPunishData(arr) {
        let punishArgume = [];
        let legalArgume = [];
        for (let i = 0; i < arr.length; i++) {
          if (arr[i].propertySmokeType == "01") {
            // 专卖案由
            punishArgume.push(arr[i].punishItem || "");
            legalArgume.push(arr[i].legalItem || "");
          } else {
            // 电子烟案由
            let xp = arr[i].smokeIllegalUuid
                ? arr[i].smokeIllegalUuid.split(",")
                : [];
            let eilist = arr[i].electricSmokeIllegalList.filter((it) => {
              return xp.includes(it.smokeIllegalUuid);
            });
            for (let j = 0; j < eilist.length; j++) {
              punishArgume.push(eilist[j].legalBasic || "");
              legalArgume.push(eilist[j].qualitativeBasic || "");
            }
          }
        }
        this.baseInfo.punishArgume = punishArgume.join(",");
        this.baseInfo.legalArgume = legalArgume.join(",");
      },
      choiceCaseOfAction(canEdit) {
        if (!canEdit) {
          return false
        }
        this.setRouteParam(this.queryRecordForm.casePropertyRelList || []);
        this.$u.route({
          url: "/pages/case/components/casePropertySelection",
          params: {
            handleProc: this.queryRecordForm.handleProc, // 获取案件类型
          },
        });
      },
		},
	};
</script>

<style lang="scss" scoped>
	@import '../case_common.scss';

	.page {
		padding: 0;
	}
</style>
